﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ibba.agil.core.common;
using ibba.agil.core;

namespace ibba.agil.data.data
{
    public class tbagi012TipoLayoKey : IDataKey
    {
        public enum enTipoConsulta
        {
            Todos = 0,
            FiltroLayou = 1
        }

        public enTipoConsulta TipoConsulta { get; set; }

        public string codTipoLayo { get; set; }
    }

    public class tbagi012TipoLayo_COL : CollectionData<tbagi012TipoLayoKey, tbagi012TipoLayo_ENT>
    {
        private manager.tbagi012TipoLayo_COM _manager;
        private Criteria<CriteriaInfo, object> _pesquisa;

        public tbagi012TipoLayo_COL()
        {
            _manager = new manager.tbagi012TipoLayo_COM();
        }

        public override List<tbagi012TipoLayo_ENT> Find(tbagi012TipoLayoKey key)
        {
            #region Implementacao do Criterio de Pesquisa

            _pesquisa = new Criteria<CriteriaInfo, object>(new tbagi012TipoLayo_ENT());

            switch (key.TipoConsulta)
            {
                case tbagi012TipoLayoKey.enTipoConsulta.FiltroLayou:
                    _pesquisa.Add(new CriteriaInfo()
                    {
                        LikePattern = LikePattern.Both,
                        LogicalType = LogicalOperator.AND,
                        NameProperty = "codTipoLayo",
                        SearchType = LogicalComparator.EQUAL
                    }, key.codTipoLayo);
                    break;
                default:
                    break;
            }
            #endregion

            return _manager.Where(CriteriaFind);
        }

        protected override Criteria<CriteriaInfo, object> CriteriaFind()
        {
            return _pesquisa;
        }

    }
}
